package system

import (
	"ginfast/app/system/api"
	"ginfast/app/system/model"
	"ginfast/pkg/ginx"
	"ginfast/pkg/orm"
)

func init() {
	orm.RegisterModel(
		&model.User{},
		&model.Role{},
		&model.Menu{},
		&model.Dept{},
		&model.DictType{},
		&model.DictData{},
		&model.Post{},
		&model.Notice{},
		&model.Config{},
		&model.LoginLog{},
	)
	ginx.Register("", func(r *ginx.RouterGroup) {
		r.POST("/system/login", api.LoginHandler)
		r.POST("/system/logout", api.LogoutHandler)
		r.GET("/system/captcha", api.CaptchaImageHandler)
		r.POST("/v1/login", api.ApiLoginHandler)
	})
	ginx.RegisterAuth("/v1/system", func(r *ginx.RouterGroup) {
		r.Register("/menu", api.Menu{}.Routers)
		r.Register("/role", api.Role{}.Routers)
		r.Register("/user", api.User{}.Routers)
		r.Register("/dept", api.Dept{}.Routers)
		r.Register("/dict/type", api.DictType{}.Routers)
		r.Register("/dict/data", api.Dict{}.Routers)
		r.Register("/post", api.Post{}.Routers)
		r.Register("/config", api.Config{}.Routers)
		r.Register("/notice", api.Notice{}.Routers)
		r.Register("/monitor", api.Monitor{}.Routers)
		r.Register("/loginLog", api.LoginLog{}.Routers)
	})
}
